package JavaProjects;
import java.util.ArrayList;
public class Arraylist_2 {
    public static void main(String[] args) {
        //定义一个集合，添加字符串，并进行遍历
        //遍历格式参照：[元素1，元素2，元素3]
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student("zhangsan", 23);
        Student s2 = new Student("lisi", 24);
        Student s3 = new Student("wangwu", 25);

        list.add(s1);
        list.add(s2);
        list.add(s3);

        for(int i = 0 ; i < list.size() ; i++){
            Student stu = list.get(i);
            System.out.println(stu.getName() + "," + stu.getAge());
        }
    }
}
